//
//  WYDepictsImageCell.m
//  Boss
//
//  Created by admin on 2018/6/8.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYDepictsImageCell.h"
#import "XHWebImageAutoSize.h"
@interface WYDepictsImageCell()

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imageHeight;
//@property (strong, nonatomic) IBOutlet UIImageView *depictsImageView;
@end
@implementation WYDepictsImageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.bottomView.hidden = YES;
    self.bottomViewHeight.constant = 0;
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setImageUrl:(NSString *)imageUrl
{
    _imageUrl = imageUrl;
    WEAKSELF
    [self.depictsImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@!default",imageUrl]] placeholderImage:[UIImage imageNamed:@""] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
 
        /** 缓存image size */
        [XHWebImageAutoSize storeImageSize:image forURL:imageURL completed:^(BOOL result) {
            /** reload  */
            if(result) {
                if ([weakSelf.delegate respondsToSelector:@selector(reloadTableView:)]) {
                    [weakSelf.delegate reloadTableView:[NSString stringWithFormat:@"%@!default",imageUrl]];
                }
            }
        }];
    }];
    self.imageHeight.constant = [XHWebImageAutoSize imageHeightForURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@!default",imageUrl]] layoutWidth:[UIScreen mainScreen].bounds.size.width-32 estimateHeight:200];
}







@end
